{% macro render_pagination(pagination, endpoint) %}
    <nav>
        <ul class="pagination">
            <li>
                <a href="{{ url_for('.home', page=pagination.prev().page) }}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            {% for page in pagination.iter_pages() %}
                {% if page %}
                    {% if page != pagination.page %}
                        <li><a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a></li>
                    {% else %}
                        <li><a href="">{{ page }}</a></li>
                    {% endif %}
                {% else %}
                    <li><a>…</a><li>
                {% endif %}
            {% endfor %}
            <li>
                <a href="{{ url_for('.home', page=pagination.next().page) }}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
    </nav>
{% endmacro %}

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>{% block title %}Blog{% endblock %}</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
    </head>
    <body>
        <div class="container">
            <div class="jumbotron">
                <h1><a href="{{ url_for('.home') }}">My Blog</a></h1>
                <p>Welcome to the blog!</p>
            </div>

            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                    {% for category, message in messages %}
                        <div class="alert alert-{{ category }} alert-dismissible" role="alert">
                          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                          {{ message }}
                        </div>
                    {% endfor %}
                {% endif %}
            {% endwith %}

            {% block body %}

            {% endblock %}
        </div>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
        {% block js %}
        {% endblock %}
    </body>
</html>